
package vistas;

import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JTextField;
import controladores.CCategoria;


public class VCategoria extends javax.swing.JFrame {

	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("com.jgoodies.looks.plastic.Plastic3DLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}


    private Vector<JTextField> edit;
    private Vector<JButton> boton;
    private CCategoria control;
    private AuxVista auxvista;


    public VCategoria() {
        initComponents();
        auxvista = new AuxVista();
        boton = new Vector<JButton>();
        control= new CCategoria(this);
        edit = new Vector<JTextField>();
        
        boton.add(btnSalir);
        boton.add(btnConsultar);
        boton.add(btnActualizar);
        boton.add(btnEliminar);
        boton.add(btnRegistrar);
        boton.add(btnCancelar);

        edit.add(txtCodigo);
        edit.add(txtDescripcion);

        for (int i = 0; i < boton.size(); i++)
            boton.elementAt(i).addActionListener(control);

    }

    public boolean validarCamposVacios(){
         return auxvista.validarCamposVacios(edit);
    }

     public void reiniciar(){
        auxvista.reiniciar(edit);
        txtCodigo.setEditable(true);
    }

    public JTextField getTxtCodigo() {
        return txtCodigo;
    }

    public JTextField getTxtDescripcion() {
        return txtDescripcion;
    }
     

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        txtDescripcion = new javax.swing.JTextField();
        txtCodigo = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        btnRegistrar = new javax.swing.JButton("Registrar");
        btnConsultar = new javax.swing.JButton("Consultar");
        btnCancelar = new javax.swing.JButton("Cancelar");
        btnSalir = new javax.swing.JButton("Salir");
        btnActualizar = new javax.swing.JButton("Actualizar");
        btnEliminar = new javax.swing.JButton("Eliminar");
        jLabel3 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Maestro de Categorias");
        getContentPane().setLayout(null);

        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.setLayout(null);
        jPanel1.add(txtDescripcion);
        txtDescripcion.setBounds(120, 70, 110, 28);

        jPanel1.add(txtCodigo);
        txtCodigo.setBounds(120, 10, 110, 28);

        jLabel2.setText("Codigo:");
        jPanel1.add(jLabel2);
        jLabel2.setBounds(20, 20, 60, 18);

        jLabel1.setText("Descripcion:");
        jPanel1.add(jLabel1);
        jLabel1.setBounds(20, 71, 100, 18);

        getContentPane().add(jPanel1);
        jPanel1.setBounds(30, 50, 280, 110);
        jPanel1.setBackground(new java.awt.Color(255,255,255));

        jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel2.setLayout(null);

        btnRegistrar.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        btnRegistrar.setText("Registrar");
        btnRegistrar.setPreferredSize(new java.awt.Dimension(80, 30));
        jPanel2.add(btnRegistrar);
        btnRegistrar.setBounds(10, 20, 120, 30);

        btnConsultar.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        btnConsultar.setText("Consultar");
        jPanel2.add(btnConsultar);
        btnConsultar.setBounds(140, 20, 120, 30);

        btnCancelar.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        btnCancelar.setText("Cancelar");
        btnCancelar.setPreferredSize(new java.awt.Dimension(80, 30));
        jPanel2.add(btnCancelar);
        btnCancelar.setBounds(10, 100, 120, 30);

        btnSalir.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        btnSalir.setText("Salir");
        jPanel2.add(btnSalir);
        btnSalir.setBounds(140, 100, 120, 30);

        btnActualizar.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        btnActualizar.setText("Actualizar");
        btnActualizar.setPreferredSize(new java.awt.Dimension(80, 30));
        jPanel2.add(btnActualizar);
        btnActualizar.setBounds(140, 60, 120, 30);

        btnEliminar.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        btnEliminar.setText("Eliminar");
        jPanel2.add(btnEliminar);
        btnEliminar.setBounds(10, 60, 120, 30);

        getContentPane().add(jPanel2);
        jPanel2.setBounds(30, 170, 280, 150);
        jPanel2.setBackground(new java.awt.Color(255,255,255));

        jLabel3.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel3.setText("Categorias");
        getContentPane().add(jLabel3);
        jLabel3.setBounds(110, 10, 120, 30);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        this.setBounds(0, 0, 343, 371);
        getContentPane().setBackground(new java.awt.Color(14,151,255));
    }// </editor-fold>//GEN-END:initComponents


    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VCategoria().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnActualizar;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnConsultar;
    private javax.swing.JButton btnEliminar;
    private javax.swing.JButton btnRegistrar;
    private javax.swing.JButton btnSalir;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTextField txtCodigo;
    private javax.swing.JTextField txtDescripcion;
    // End of variables declaration//GEN-END:variables

}
